<?php

class Admin_Model_Province extends Zend_Db_Table_Abstract
{
    protected $_name = 'province';
    public function getAllData(){
    	$query = $this->select()
                        ->from($this->_name);
    	return $this->fetchAll($query);
    }
    public function getDataByprovinceid($proId){
        $query = $this->select()                        
                        ->from($this->_name)
                        ->where('provinceid = ?',(int)$proId);
        return $this->fetchRow($query);
    }
    public function getDataByType($type){
        $query = $this->select()                        
                        ->from($this->_name)
                        ->where("type = '".$type."'");
        return $this->fetchAll($query);
    }        
    public function addData($data){        
        $data = array('provinceid'=> $data['provinceid'],
                'name'  => $data['name'],                
                'type'   => $data['type']);                                
        $idAdd = $this->insert($data);        
        return $idAdd;
    }
    public function updateData($proId = '',$data){        
        $data = array('name'  => $data['name'],                
                'type'     => $data['type']);                            
        return $this->update($data, 'provinceid = '.(int)$proId);
    }            
    public function deleteData($id){        
        $this->delete('provinceid = '.(int)$id);
    }
}

